<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateWebLogTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::dropIfExists('web_log');
        Schema::create('web_log', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('path')->default('')->comment('请求路径');
            $table->string('action')->default('')->comment('请求控制器:方法');
            $table->string('method')->default('')->comment('请求类型');
            $table->json('params')->nullable()->comment('请求参数');
            $table->ipAddress('remote_ip')->nullable()->comment('远程地址');
            $table->string('agent', 2000)->default('')->comment('设备信息');
            $table->bigInteger('user_id')->nullable()->comment('用户id');
            $table->string('user_name')->nullable()->comment('用户名称');
            $table->string('operation')->default('')->comment('操作描述');
            $table->string('type')->default('')->comment('类型: 1 普通用户 2 企业用户 3 管理员用户');
            $table->timestamps();
            $table->softDeletes();
            $table->comment('api 请求日志');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('web_log', function (Blueprint $table) {
            //
        });
    }
}
